<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>服务申请</title>
    <link rel="stylesheet" href="/pear/component/layui/css/layui.css">
    <script src="/pear/component/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="" style="margin-right: 15px">
    <div class="layui-form-item" style="margin-top: 30px">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text"lay-verify="required" id="userName" value="绑定的用户名" readonly autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">服务类型</label>
        <div class="layui-input-block">
            <select name="serviceType" id="serviceType" lay-verify="required">
                <option value=""></option>
                <option value="上门服务">上门服务</option>
                <option value="在线咨询">在线咨询</option>
                <option value="电话沟通">电话沟通</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择日期</label>
        <div class="layui-input-block">
            <input type="text"lay-verify="required" id="calender" class="layui-input" autocomplete="off">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">需求说明</label>
        <div class="layui-input-block">
            <textarea name="desc" placeholder="请输入问题的详细描述" class="layui-textarea" id="content"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>

    layui.use(['form','laydate','layer'], function(){
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer,
            $ = layui.jquery;
        laydate.render({
        	elem: '#calender'
        });

        //监听提交
        form.on('submit(formDemo)', function(data){
            var userName = $('#userName').val();
            var serviceType = $('#serviceType').val();
            var calender = $('#calender').val();
            var content = $('#content').val();
            // 发起ajax请求
            $.ajax({
                url:'/customer/apply',
                data:{"userName":userName,"serviceType":serviceType,"calender":calender,"content":content},
                success:function (data) {
                    if (data==="申请成功"){
                        //当你在iframe页面关闭自身时
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }else {
                        layer.msg('申请失败');
                    }
                }
            })




        });
    });
</script>
</body>
</html>